package lcmpt;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JSplitPane;
import javax.swing.JScrollPane;
import javax.swing.JEditorPane;
import javax.swing.JTree;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextPane;
import java.awt.ComponentOrientation;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import java.awt.Font;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import javax.swing.JSeparator;

public class GUI extends JFrame {

	private JPanel contentPane;

	JComboBox<String> comboBoxNames;
	JSplitPane splitPaneTreeInfo;
	JTree tree;
	JEditorPane editorPaneInfo;
	JScrollPane scrollPaneInfo;
	JScrollPane scrollPaneTree;
	private JLabel lblPfade;
	JTextPane editorPanePaths;
	private JPanel panelPaths;
	private JPanel panelCombo;
	private JMenuBar menuBar;
	private JMenu mnDatei;
	JRadioButtonMenuItem mntmLcmptAusArchiv;
	JRadioButtonMenuItem mntmLcmptAusNetz;
	JRadioButtonMenuItem mntmLcgftAusArchiv;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	JSeparator separator;
	JMenuItem mntmBeenden;
	

	/**
	 * Create the frame.
	 */
	public GUI() {
		setTitle("Hierarchische Darstellung von LCMPT und LCGFT");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1196, 732);

		menuBar = new JMenuBar();
		setJMenuBar(menuBar);

		mnDatei = new JMenu("Datei");
		menuBar.add(mnDatei);

		mntmLcmptAusArchiv = new JRadioButtonMenuItem("LCMPT aus Archiv");
		mntmLcmptAusArchiv.setSelected(true);
		buttonGroup.add(mntmLcmptAusArchiv);
		mnDatei.add(mntmLcmptAusArchiv);

		mntmLcmptAusNetz = new JRadioButtonMenuItem("LCMPT aus Netz");
		buttonGroup.add(mntmLcmptAusNetz);
		mnDatei.add(mntmLcmptAusNetz);
		
		mntmLcgftAusArchiv = new JRadioButtonMenuItem("LCGFT aus Archiv");
		buttonGroup.add(mntmLcgftAusArchiv);
		mnDatei.add(mntmLcgftAusArchiv);
		
		separator = new JSeparator();
		mnDatei.add(separator);
		
		mntmBeenden = new JMenuItem("Beenden");
		mntmBeenden.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
                dispose();
                System.exit(0);
			}
		});
		mnDatei.add(mntmBeenden);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);

		JPanel panelSearch = new JPanel();
		panelSearch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
		contentPane.add(panelSearch, BorderLayout.NORTH);
		panelSearch.setLayout(new BoxLayout(panelSearch, BoxLayout.Y_AXIS));

		panelCombo = new JPanel();
		FlowLayout fl_panelCombo = (FlowLayout) panelCombo.getLayout();
		fl_panelCombo.setAlignment(FlowLayout.LEFT);
		panelSearch.add(panelCombo);

		JLabel lblSuchbegriff = new JLabel("Suchbegriff: ");
		panelCombo.add(lblSuchbegriff);

		comboBoxNames = new JComboBox<String>();
		panelCombo.add(comboBoxNames);

		panelPaths = new JPanel();
		FlowLayout fl_panelPaths = (FlowLayout) panelPaths.getLayout();
		fl_panelPaths.setAlignment(FlowLayout.LEFT);
		panelSearch.add(panelPaths);

		lblPfade = new JLabel("Pfad(e): ");
		panelPaths.add(lblPfade);

		editorPanePaths = new JTextPane();
		editorPanePaths.setOpaque(false);
		editorPanePaths.setEditable(false);
		panelPaths.add(editorPanePaths);

		splitPaneTreeInfo = new JSplitPane();
		splitPaneTreeInfo.setDividerSize(3);
		contentPane.add(splitPaneTreeInfo, BorderLayout.CENTER);

		scrollPaneTree = new JScrollPane();
		splitPaneTreeInfo.setLeftComponent(scrollPaneTree);

		tree = new JTree();
		tree.setModel(null);
		scrollPaneTree.setViewportView(tree);

		scrollPaneInfo = new JScrollPane();
		splitPaneTreeInfo.setRightComponent(scrollPaneInfo);

		editorPaneInfo = new JEditorPane();
		editorPaneInfo.setFont(new Font("Tahoma", Font.PLAIN, 13));
		editorPaneInfo.setEditable(false);
		editorPaneInfo.setContentType("text/html");
		scrollPaneInfo.setViewportView(editorPaneInfo);
	}

}
